#include<vector>
using namespace std;

class Solution {
public:
    int maxChunksToSorted(vector<int>& arr) {
        int max = INT32_MIN;
        int res = 0;
        for (int i = 0; i < arr.size(); ++i) {
            if (arr[i] > max)
                max = arr[i];
            if (max == i)
                ++res;
        }
        return res;
    }
};